#include "../mytcp.h"

#define TCP_SERVER_IP "192.168.31.13"
#define TCP_SERVER_PORT 55555

int main(int argc, char const *argv[])
{
    int Ret;
    
    int ClintSockFd;
    Ret = TcpClintConnect( &ClintSockFd, TCP_SERVER_IP, TCP_SERVER_PORT );
    if ( -1 == Ret )
    {
        perror( "fail TcpClintConnect" );
        return -1;
    }
    printf( "Success connect TCP server %s:%d\n", TCP_SERVER_IP, TCP_SERVER_PORT );

    ssize_t SizeRet;
    char SendBuff[100] = "Hello, This is TCP Clint";
    SizeRet = send( ClintSockFd, SendBuff, strlen(SendBuff) + 1, 0 );
    if ( -1 == SizeRet )
    {
        perror( "fail send" );
        return -1;
    }
 
    char RecvBuff[100] = {0};
    SizeRet = recv( ClintSockFd, RecvBuff, sizeof(RecvBuff), 0 );
    if ( -1 == SizeRet )
    {
        perror( "fail recv" );
        return -1;
    }
    printf( "Recv from TCP Server: %s\n", RecvBuff );
    
    return 0;
}
